package HTMLParser;

import java.io.IOException;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class HTMLParserExample6GleCongdongparse {

	public static void main(String[] args) {
		StringBuffer stbEN = new StringBuffer();
		StringBuffer stbVN = new StringBuffer();

		StringBuffer stbKethop = new StringBuffer();
		Document doc;
		String link;
		try {
			for (int i = 1; i < 32; i++) {
				// get all images

				link = "http://tratu.vietgle.vn/hoc-tieng-anh/cap-cau-song-ngu/cong-dong/tat-ca/trang-"
						+ i + ".html";
				doc = Jsoup.connect(link).get();
				// p10l icham

				Elements byClass = doc.getElementsByClass("icham");
				Elements byClass_vi = doc.getElementsByClass("p10l");

//				System.out
//						.println("So luong cau tieng anh = " + byClass.size());
//				System.out.println("So luong cau tieng viet = "
//						+ byClass_vi.size());
//				System.out.println("line Sep =" + System.getProperty("line.")
//						+ "line Sep =");
//				System.out.println("tab" + "\t" + "tab");
//				for (Element byClas : byClass) {
//					// System.out.println(byClas.ownText());
//					stbEN.append(byClas.ownText());
//					stbEN.append("\t");
//				}
//				for (Element byClass_vi_e : byClass_vi) {
//					// System.out.println(byClass_vi_e.ownText());
//					stbVN.append(byClass_vi_e.ownText());
//					stbVN.append("\t");
//				}
				for (int i1 = 0; i1 < byClass.size(); i1++) {
					stbKethop.append(byClass.get(i1).text()+"\t");
					//stbVN.append("\t");
					stbKethop.append(byClass_vi.get(i1 + 1).text()+"\n");
					//stbVN.append("\n");
				}

			}

		} catch (IOException e) {
			e.printStackTrace();
		}
//		System.out.println(stbEN.toString());
//		System.out.println(stbVN.toString());
		System.out.println(stbKethop.toString());

	}
}
